package cn.amao.pujintest2.pages;

import cn.amao.pujintest2.base.PageAppium;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

public class LoginPage extends PageAppium {

    private static final String WELCOME_JUMP_BUTTON_ID = "stv_jump";
    private static final String WELECOM_ACTIVITY_NAME = "SplashActivity";
    private static final String Login_ACTIVITY_NAME = "LoginActivity";
    private static final String LOGIN_BUTTON_ID = "btn_login";
    private static final String HOME_TAB_ACTIVITY_VIEW_ID = "btv_tabs";

    public LoginPage(AndroidDriver driver){
        super(driver);
    }
    /**
     * 是否在欢迎界面
     */
    public boolean isWelcome(){
        return isIdElementExist(WELCOME_JUMP_BUTTON_ID,10,true);
    }

    public String getLoginActivityName(){
        return Login_ACTIVITY_NAME;
    }

    public String getSplashActivityName() {
        return WELECOM_ACTIVITY_NAME;
    }
    public static String getSplahJumpViewId(){
        return WELCOME_JUMP_BUTTON_ID;
    }

    public AndroidElement getLoginButton(){
        return findById(LOGIN_BUTTON_ID);
    }

    public String getHomeTabActivityElementId() {
        return HOME_TAB_ACTIVITY_VIEW_ID;
    }

    /**
     * 首页标识，是否成功登录
     * @return
     */
    public boolean getHomeTabflag(){
        /*AndroidElement element =  waitAutoByXp(LoginPage.INDEX_TEXT);
        return  element != null;*/

        AndroidElement element = findById(HOME_TAB_ACTIVITY_VIEW_ID);
        return element != null;
    }
}
